//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class Colors : IOfficeXmlSerializableAs
    {
        readonly List<ColorBase>_list = new List<ColorBase>();
        private ColorApplicationMethod _meth;
        private HueDirection _hueDir;

        public void ReadXmlAs(string name, ReadContext context) 
        {
            using (var c = context.Read(name))
            {
                _meth = c.GetOptionalEnum("meth", ColorApplicationMethod.Span);
                _hueDir = c.GetOptionalEnum("hueDir", HueDirection.Clockwise);
                while (c.ReaderLocalName != null)
                    _list.Add(ColorBase.ReadOptionalColor(c)); //\\ sure?
            }

        }
        public void WriteXmlAs(string name, WriteContext context) 
        {
            using (var c = context.Write(name))
            {
                c.SetOptionalEnum("meth", _meth, ColorApplicationMethod.Span);
                c.SetOptionalEnum("hueDir", _hueDir, HueDirection.Clockwise);
                c.WriteElements(_list);
            }
        }

   }
}